Skip to content

lib: use Object.freeze to avoid defensive cloning in SourceMap#62830

Merged
aduh95 merged 4 commits into
nodejs:mainfrom
watilde:fixes-memory-sourcemap
May 19, 2026
Merged

lib: use Object.freeze to avoid defensive cloning in SourceMap#62830
aduh95 merged 4 commits into
nodejs:mainfrom
watilde:fixes-memory-sourcemap

Conversation

@watilde
Copy link
Copy Markdown
Member

@watilde watilde commented Apr 19, 2026

No description provided.

@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Apr 19, 2026
@watilde watilde force-pushed the fixes-memory-sourcemap branch from 3b8cc82 to 73ffd8a Compare April 19, 2026 10:40
@watilde watilde changed the title perf: use Object.freeze to avoid defensive cloning in SourceMap lib: use Object.freeze to avoid defensive cloning in SourceMap Apr 19, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 19, 2026

Codecov Report

βœ… All modified and coverable lines are covered by tests.
βœ… Project coverage is 89.65%. Comparing base (d44a71a) to head (673e0a2).
⚠️ Report is 264 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #62830      +/-   ##
==========================================
+ Coverage   89.61%   89.65%   +0.03%     
==========================================
  Files         706      706              
  Lines      219203   219389     +186     
  Branches    41995    42061      +66     
==========================================
+ Hits       196445   196692     +247     
+ Misses      14663    14589      -74     
- Partials     8095     8108      +13     
Files with missing lines Coverage Ξ”
lib/internal/source_map/source_map.js 99.48% <100.00%> (+0.25%) ⬆️

... and 49 files with indirect coverage changes

πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • πŸ“¦ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@legendecas legendecas added semver-major PRs that contain breaking changes and should be released in the next major version. source maps Issues and PRs related to source map support. labels Apr 20, 2026
Copy link
Copy Markdown
Member

@legendecas legendecas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind adding a note on https://github.com/nodejs/node/blob/main/doc/api/module.md#sourcemappayload that the returned payload is frozen? Thanks!

Copy link
Copy Markdown
Member

@legendecas legendecas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind fixing the linter complaints? Thanks

Comment thread doc/api/module.md
@watilde watilde force-pushed the fixes-memory-sourcemap branch from bd11c1e to f5cc42f Compare April 23, 2026 10:36
@watilde watilde force-pushed the fixes-memory-sourcemap branch from f5cc42f to f493f69 Compare April 23, 2026 11:04
@watilde
Copy link
Copy Markdown
Member Author

watilde commented Apr 23, 2026

Fix, rebase and make the commit Verified.

@legendecas legendecas added the commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. label Apr 23, 2026
Co-authored-by: Chengzhong Wu <legendecas@gmail.com>
@watilde watilde added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 23, 2026
@watilde watilde removed needs-ci PRs that need a full CI run. request-ci Add this label to start a Jenkins CI on a PR. labels Apr 25, 2026
@legendecas legendecas added request-ci Add this label to start a Jenkins CI on a PR. needs-ci PRs that need a full CI run. labels Apr 25, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 25, 2026
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@legendecas legendecas added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 27, 2026
@watilde watilde removed the needs-ci PRs that need a full CI run. label May 15, 2026
@aduh95 aduh95 added the commit-queue Add this label to land a pull request using GitHub Actions. label May 19, 2026
@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels May 19, 2026
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/62830
βœ”  Done loading data for nodejs/node/pull/62830
----------------------------------- PR info ------------------------------------
Title      lib: use Object.freeze to avoid defensive cloning in SourceMap (#62830)
Author     Daijiro Wachi <daijiro.wachi@gmail.com> (@watilde)
Branch     watilde:fixes-memory-sourcemap -> nodejs:main
Labels     semver-major, author ready, source maps, commit-queue-squash
Commits    4
 - lib: use Object.freeze to avoid defensive cloning in SourceMap
 - doc: clarify sourceMap.payload behavior and immutability
 - doc: add change metadata for validator message
 - doc: fix unclosed YAML comment in sourceMap.payload
Committers 2
 - Daijiro Wachi <daijiro.wachi@gmail.com>
 - GitHub <noreply@github.com>
PR-URL: https://github.com/nodejs/node/pull/62830
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/62830
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
--------------------------------------------------------------------------------
   β„Ή  This PR was created on Sun, 19 Apr 2026 10:37:36 GMT
   βœ”  Approvals: 1
   βœ”  - Chengzhong Wu (@legendecas) (TSC): https://github.com/nodejs/node/pull/62830#pullrequestreview-4175823264
   ✘  semver-major requires at least 2 TSC approvals
   βœ”  Last GitHub CI successful
   β„Ή  Last Full PR CI on 2026-04-25T16:24:18Z: https://ci.nodejs.org/job/node-test-pull-request/72922/
- Querying data for job/node-test-pull-request/72922/
βœ”  Build data downloaded
   βœ”  Last Jenkins CI successful
--------------------------------------------------------------------------------
   βœ”  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/26103949075

@legendecas
Copy link
Copy Markdown
Member

Given that this is a breaking change, this needs another @nodejs/tsc review, thanks!

@legendecas legendecas added commit-queue Add this label to land a pull request using GitHub Actions. and removed commit-queue-failed An error occurred while landing this pull request using GitHub Actions. labels May 19, 2026
@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels May 19, 2026
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/62830
βœ”  Done loading data for nodejs/node/pull/62830
----------------------------------- PR info ------------------------------------
Title      lib: use Object.freeze to avoid defensive cloning in SourceMap (#62830)
Author     Daijiro Wachi <daijiro.wachi@gmail.com> (@watilde)
Branch     watilde:fixes-memory-sourcemap -> nodejs:main
Labels     semver-major, author ready, source maps, commit-queue-squash
Commits    4
 - lib: use Object.freeze to avoid defensive cloning in SourceMap
 - doc: clarify sourceMap.payload behavior and immutability
 - doc: add change metadata for validator message
 - doc: fix unclosed YAML comment in sourceMap.payload
Committers 2
 - Daijiro Wachi <daijiro.wachi@gmail.com>
 - GitHub <noreply@github.com>
PR-URL: https://github.com/nodejs/node/pull/62830
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/62830
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
--------------------------------------------------------------------------------
   β„Ή  This PR was created on Sun, 19 Apr 2026 10:37:36 GMT
   βœ”  Approvals: 2
   βœ”  - Chengzhong Wu (@legendecas) (TSC): https://github.com/nodejs/node/pull/62830#pullrequestreview-4175823264
   βœ”  - Yagiz Nizipli (@anonrig) (TSC): https://github.com/nodejs/node/pull/62830#pullrequestreview-4320305018
   βœ”  Last GitHub CI successful
   β„Ή  Last Full PR CI on 2026-05-19T14:32:59Z: https://ci.nodejs.org/job/node-test-pull-request/72922/
- Querying data for job/node-test-pull-request/72922/
βœ”  Build data downloaded
   βœ”  Last Jenkins CI successful
--------------------------------------------------------------------------------
   βœ”  No git cherry-pick in progress
   βœ”  No git am in progress
   βœ”  No git rebase in progress
--------------------------------------------------------------------------------
- Bringing origin/main up to date...
From https://github.com/nodejs/node
 * branch                  main       -> FETCH_HEAD
βœ”  origin/main is now up-to-date
- Downloading patch for 62830
From https://github.com/nodejs/node
 * branch                  refs/pull/62830/merge -> FETCH_HEAD
βœ”  Fetched commits as 783b38248310..673e0a2285e9
--------------------------------------------------------------------------------
[main 69cf5e6625] lib: use Object.freeze to avoid defensive cloning in SourceMap
 Author: Daijiro Wachi <daijiro.wachi@gmail.com>
 Date: Sun Apr 19 19:40:37 2026 +0900
 2 files changed, 19 insertions(+), 8 deletions(-)
Auto-merging doc/api/module.md
[main 9ca29e4b19] doc: clarify sourceMap.payload behavior and immutability
 Author: Daijiro Wachi <daijiro.wachi@gmail.com>
 Date: Thu Apr 23 19:36:22 2026 +0900
 1 file changed, 4 insertions(+)
Auto-merging doc/api/module.md
[main 7b0a139518] doc: add change metadata for validator message
 Author: Daijiro Wachi <daijiro.wachi@gmail.com>
 Date: Fri Apr 24 02:52:24 2026 +0900
 1 file changed, 5 insertions(+)
Auto-merging doc/api/module.md
[main 4251de19a1] doc: fix unclosed YAML comment in sourceMap.payload
 Author: Daijiro Wachi <daijiro.wachi@gmail.com>
 Date: Sat Apr 25 18:32:39 2026 +0900
 1 file changed, 2 insertions(+)
   βœ”  Patches applied
There are 4 commits in the PR. Attempting to fixup everything into first commit.
[main 1bd0ca9117] lib: use Object.freeze to avoid defensive cloning in SourceMap
 Author: Daijiro Wachi <daijiro.wachi@gmail.com>
 Date: Sun Apr 19 19:40:37 2026 +0900
 3 files changed, 30 insertions(+), 8 deletions(-)
--------------------------------- New Message ----------------------------------
lib: use Object.freeze to avoid defensive cloning in SourceMap

PR-URL: #62830
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>

[main c2e25ee445] lib: use Object.freeze to avoid defensive cloning in SourceMap
Author: Daijiro Wachi <daijiro.wachi@gmail.com>
Date: Sun Apr 19 19:40:37 2026 +0900
3 files changed, 30 insertions(+), 8 deletions(-)
βœ– c2e25ee4458f66a963f8dfaa3f456d6744cdf674
βœ” 0:0 no Assisted-by metadata assisted-by-is-trailer
βœ” 0:0 no Co-authored-by metadata co-authored-by-is-trailer
βœ” 0:0 skipping fixes-url fixes-url
βœ” 0:0 blank line after title line-after-title
βœ” 0:0 line-lengths are valid line-length
βœ” 0:0 metadata is at end of message metadata-end
βœ” 1:8 PR-URL is valid. pr-url
βœ” 0:0 reviewers are valid reviewers
βœ– 0:0 Commit must have a "Signed-off-by" trailer signed-off-by
βœ” 0:0 valid subsystems subsystem
βœ” 0:0 Title is formatted correctly. title-format
⚠ 0:50 Title should be <= 50 columns. title-length

β„Ή Please fix the commit message and try again.
Please manually ammend the commit message, by running
git commit --amend
Once commit message is fixed, finish the landing command running
git node land --continue

https://github.com/nodejs/node/actions/runs/26114797253

@aduh95 aduh95 merged commit b1387e6 into nodejs:main May 19, 2026
87 checks passed
@aduh95
Copy link
Copy Markdown
Contributor

aduh95 commented May 19, 2026

Landed in b1387e6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue-failed An error occurred while landing this pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. semver-major PRs that contain breaking changes and should be released in the next major version. source maps Issues and PRs related to source map support.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants